<template>
  <div>
    <el-select v-model="form.label" :size="formSize" multiple collapse-tags placeholder="请选择标签" @change="onChange">
      <el-option v-for="item in tagsList" :key="item.id" :label="item.name" :value="item.name">
      </el-option>
    </el-select>
  </div>
</template>
<script>
import { GET_ALL_TAGS_LIST } from "@/http/customer";
export default {
  name: "LabelSelect",
  data() {
    return {
      tagsList: [],
      formSize: "small",
      form: {},
    };
  },
  mounted() {
    this.getLabels();
  },
  methods: {
    // 获取所有标签
    getLabels() {
      GET_ALL_TAGS_LIST().then((res) => {
        this.tagsList = res.data || [];
      });
    },

    // 监听标签选择
    onChange(e) {
      console.log(e);
      this.$emit("input", e.toString());
    },
  },
};
</script>
<style lang="scss" scoped>
</style>